<!DOCTYPE html>
<html>

<head>
	<title>作业</title>
</head>
<body>
<script>

var arrayOld=[1,2,3,4,2,6,2];
var arrayNew=[];
for(var i=0;i<arrayOld.length;i++){
	if(arrayOld[i]==2){
		arrayNew.push(arrayOld[i]);
		arrayOld.splice(i,1);
	}
}
document.write(arrayNew);
document.write("        ")
document.write(arrayOld);


</script>
</body>

</html>